
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8"/>
    <base href="/">
    <title>购物车</title>
    <base th:href="${#request.getContextPath()}+'/'">
    <link rel="stylesheet" type="text/css" href="css/public.css"/>
    <link rel="stylesheet" type="text/css" href="css/myorder.css"/>
</head>
<body><!------------------------------head------------------------------>
<div class="head">
    <div class="wrapper clearfix">
        <div class="clearfix" id="top">
            <h1 class="fl"><a href="User/loginGet"><img src="img/logo.png"/></a></h1>
            <ul class="clearfix" id="bott">
                <li><a href="User/loginGet">首页</a></li>
                <li th:each="productTypes:${productTypes}">
                    <a th:text="${productTypes.productTypeName}" th:href="'User/mushrooms?id='+${productTypes.productTpyeId}"></a>
                </li>
            </ul>
            <div class="fr clearfix" id="top1">
                <p class="fl"  th:if="${session.Userinfo == null}" >
                    <a href="User/loginUser" id="login">登录</a><a href="User/register" id="reg">注册</a>
                </p>
                <p class="fl"  th:if="${session.Userinfo != null}" >
                    <a href="User/Upersonal_center" th:text="'亲爱的'+${session.Userinfo.userName}+'，欢迎登录！'"></a><a href="User/backUserLogin">退出登录</a>
                </p>
                <div class="btn fl clearfix">
                    <a href="User/Upersonal_center"><img src="img/grzx.png"/></a>
                    <a href="User/Ushoppingcart"><img src="img/gwc.png"/></a>
                </div>
            </div>
        </div>
    </div>
</div>
<!------------------------------idea------------------------------>
<div class="address mt">
    <div class="wrapper clearfix"><a href="User/loginGet" class="fl">首页</a><span>/</span><a href="User/Ushoppingcart" class="on">我的购物车</a></div>
</div><!------------------------------Bott------------------------------>
<div class="Bott">
    <div class="wrapper clearfix">
        <div class="zuo fl">

            <div><h4>我的交易</h4>
                <ul>
                    <li class="on">
                        <a href="User/Ushoppingcart">我的购物车</a>
                    </li>
                    <li><a href="User/Myorderq">我的订单</a></li>
                </ul>
                <h4>个人中心</h4>
                <ul>
                    <li><a href="User/Upersonal_center">我的中心</a></li>
                </ul>
                <h4>账户管理</h4>
                <ul>
                    <li ><a href="User/Upersonalinfor">个人信息</a></li>
                    <li><a href="User/Uchangepassword">修改密码</a></li>
                </ul>
            </div>
        </div>
        <div class="you fl">
            <div class="my clearfix"><h2 class="fl">我的购物车</h2></div>
            <div class="dlist clearfix">
                <ul class="fl clearfix" id="wa">
                    <li class="on"><a href="User/Myorderq">全部商品</a></li>
                </ul>
                <!--                <form action="#" method="get" class="fr clearfix">-->
                <!--                    <input type="text" name="" value="" placeholder="请输入商品名称、订
                家用创意菜盘子圆盘 釉下彩复古
                ¥99.00×1单号"/><input type="button" name="" id="" value=""/>-->
                <!--                </form>-->
            </div>
            <!--            <div class="dkuang"><p class="one">已收货</p>-->
            <!--                <div class="word clearfix">-->
            <!--                    <ul class="fl clearfix">-->
            <!--                        <li>2016年12月1日 18:53</li>-->
            <!--                        <li>杨小黄</li>-->
            <!--                        <li>订单号:5160513358520018</li>-->
            <!--                        <li>在线支付</li>-->
            <!--                    </ul>-->
            <!--                    <p class="fr">订单金额：<span>99.00</span>元</p></div>-->
            <!--                <div class="shohou clearfix"><a href="#" class="fl"><img src="img/g1.jpg"/></a>-->
            <!--                    <p class="fl"><a href="#">家用创意菜盘子圆盘 釉下彩复古</a><a href="#">¥99.00×1</a></p>-->
            <!--                    <p class="fr"><a href="myprod.html">待评价</a><a href="orderxq.html">订单详情</a></p></div>-->
            <!--            </div>-->





            <div class="dkuang clearfix deng" th:each="shoppingCarts:${shoppingCarts}">
                <div class="word clearfix" style="border-bottom: none" >
                    <p class="fr">订单金额：<span th:text="${shoppingCarts.shoppingTotalPrice}"></span>元</p></div>
                <div class="shohou clearfix"><a href="#" class="fl"><img th:src="${shoppingCarts.Product.productImage}"/></a>
                    <p class="fl"><a th:text="${shoppingCarts.Product.productName}"></a>
                        <a th:text="${'¥'+shoppingCarts.Product.productPrice+'×'+shoppingCarts.shoppingCount}"></a></p>
                    <p class="fr">
                        <a th:onclick="finishShopCart([[${shoppingCarts}]])">确认购买</a>
                        <a th:onclick="'javascript:UDelShoppingcart('+${shoppingCarts.shoppingId}+')'">删除商品</a>
                    </p>
                </div>
            </div>

            <div class="dkuang clearfix deng" style="border: none" >
                <div class="shohou clearfix">
                    <p class="fr">
                        <a th:onclick="'javascript:UDelShoppingcartAll('+${session.Userinfo.getUserId()}+')'">清空购物车</a>
                    </p>
                </div>
            </div>


        </div>
    </div>
</div><!--返回顶部-->
<div class="gotop">
    <a href="User/Ushoppingcart">
    <dl>
        <dt><img src="img/gt1.png"/></dt>
        <dd>去购<br/>物车</dd>
    </dl>
    </a>
    <a href="User/Upersonal_center">
    <dl>
        <dt><img src="img/gt3.png"/></dt>
        <dd>个人<br/>中心</dd>
    </dl>
    </a>
    <p>400-800-8200</p></div><!--footer-->
<div class="footer">
    <div class="top">
        <div class="wrapper">
            <div class="clearfix"><a class="fl"><img src="img/foot1.png"/></a><span class="fl">7天无理由退货</span>
            </div>
            <div class="clearfix"><a class="fl"><img src="img/foot2.png"/></a><span class="fl">15天免费换货</span>
            </div>
            <div class="clearfix"><a class="fl"><img src="img/foot3.png"/></a><span class="fl">满599包邮</span>
            </div>
            <div class="clearfix"><a class="fl"><img src="img/foot4.png"/></a><span class="fl">手机特色服务</span>
            </div>
        </div>
    </div>
    <p class="dibu">绿色农业商城&copy;2013-2023公司版权所有 京ICP备080100-44备0000111000号<br/>
    </p></div>
<script src="js/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/public.js" type="text/javascript" charset="utf-8"></script>
<script src="js/user.js" type="text/javascript" charset="utf-8"></script>
<script>
    //删除购物车中的一个商品
    function UDelShoppingcart(id){
        $.get("User/UDelShoppingcart",{
            'id': id
        },function (response){
            if (response.res=="ok"){
                alert(response.msg);
            }else {
                alert(response.msg)
            }
            window.location.href="/User/Ushoppingcart"
        })
    }
    //清空该用户的购物车
    function UDelShoppingcartAll(id){
        $.get("User/UDelShoppingcartAll",{
            'id': id
        },function (response){
            if (response.res=="ok"){
                alert(response.msg);
            }else {
                alert(response.msg)
            }
            window.location.href="/User/Ushoppingcart"
        })
    }

    //结算功能
    function finishShopCart(shoppingCarts){
        console.log(shoppingCarts)
        console.log(shoppingCarts.shoppingId)
        console.log(shoppingCarts.product.productId)
        console.log(shoppingCarts.shoppingCount)
        console.log(shoppingCarts.product.productPrice)
        console.log(shoppingCarts.shoppingTotalPrice)
        console.log(shoppingCarts.producer.producerId)

        $.post("User/finishShopCarts",{
            'producerId':shoppingCarts.producer.producerId,
            'shoppingCartId':shoppingCarts.shoppingId,
            'productId':shoppingCarts.product.productId,
            'count': shoppingCarts.shoppingCount,
            'productPrice': shoppingCarts.product.productPrice,
            'productPriceTotal': shoppingCarts.shoppingTotalPrice,
        },function (response){
            console.log(response)
            alert(response.msg)
            if (response.res == 1) {
                window.location.href='/User/Myorderq'
            }
        })
    }

</script>

</body>
</html>